<template>
  <div class="mains">
    <div class="frist">
      <div class="titles">田块地类分布（公顷）</div>
      <div class="echarts">
        <echart :options="option1"/>
      </div>
    </div>
    <div class="two">
      <div class="titles">高标准农田 项目列表</div>
      <div class="select">
        <input type="text" placeholder="请输入地块名称或者地块编码查询">
        <div class="sousuo"></div>
      </div>
      <div class="table-main">
        <div class="thead">
          <div class="trs">
            <div>项目编号</div>
            <div>项目位置</div>
            <div>操作</div>
          </div>
        </div>
        <div class="tbody" ref="generalTable" @mouseover.stop="generalTableOver()" @mouseleave.stop="generalTableStart()">
          <div class="trs" v-for="item in datas">
            <div>{{item.name}}</div>
            <div>{{item.location}}</div>
            <div>查看</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Echart from '@/components/echart/Echart.vue';
import {rightEchart} from '../echarts/echart'
export default {
  components: { Echart },
  data() {
    return {
      datas: [{
        name: '0001',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0002',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0003',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0004',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0005',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0006',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0007',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0008',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0009',
        location: '承德县智慧农田',
        coding: 4722
      },{
        name: '0010',
        location: '承德县智慧农田',
        coding: 4722
      }],
      option1:undefined,
      timer1: undefined,
    };
  },
  created() {
    this.setEcharts();
  },
  mounted() {
    this.generalTableStart()
  },

  methods: {
    setEcharts() {
      this.option1 = rightEchart();
    },
    // 自动循环播放
    generalTableStart(){
       //业务告警
      const wrapper1 = this.$refs.generalTable
      this.timer1 = setInterval(() => {
        wrapper1.scrollTop += 1
        if (wrapper1.clientHeight + wrapper1.scrollTop == wrapper1.scrollHeight) {
          wrapper1.scrollTop = wrapper1.scrollTop - wrapper1.scrollHeight/2
        }
      }, 60)
    },
    // 清除业务告警
    generalTableOver(){
      clearInterval(this.timer1)
    }
  },
  destroyed() {
    clearInterval(this.timer1) // 清除定时器
  }
};
</script>

<style lang="scss" scoped>
.mains {
  margin-top: 117px;
  height: calc(100% - 117px - 30px);
  margin-left: 20px;
  .titles {
    width: 100%;
    height: 36px;
    line-height: 36px;
    font-size: 24px;
    font-family: ysbt;
    background: url(~assets/images/title_bg.png) no-repeat;
    background-size: 100% 100%;
    padding-left: 15px;
    text-shadow: 0 0 10px #fff,0 0 20px #1862b4,0 0 30px #1862b4;
  }
  .frist {
    height: 300px;
    .echarts {
      height: calc(100% - 36px);
      background: url(~assets/images/rightbg.png) no-repeat center;
      background-size: 250px 250px;
    }
  }
  .two {
    width: 100%;
    height: calc(100% - 300px);
    .select {
      margin-top: 10px;
      width: 100%;
      height: 50px;
      padding: 0 3px;
      input {
        background-color: transparent;
        border: 0;
        color: #9AE0E6;
        height: 100%;
        width: 80%;
        &::placeholder {
          color: #9AE0E6;
        }
      }
      border-top: 2px solid;
      border-bottom: 2px solid;
      /*设置线性渐变*/
      border-image: linear-gradient(to right, #62BBFF 10%, rgba(255, 255, 255, 0) 100%) 2 2 2 2;
      display: flex;
      align-items: center;
      .sousuo {
        width: 20px;
        height: 20px;
        background: url(~assets/images/sousuo.png) no-repeat;
        background-size: 100% 100%;
        margin-left: 20px;
      }
    }
    .table-main {
      font-size: 14px;
      width: 100%;
      margin-top: 10px;
      height: calc(100% - 36px - 50px - 20px);
      .thead {
        line-height: 36px;
        background: url(~assets/images/tabtop.png) no-repeat;
        background-size: 100% 100%;
        .trs {
          div {
            color: #ACCCF1 !important;
          }
        }
      }
      .tbody {
        line-height: 40px;
        margin-top: 20px;
        height: calc(100% - 36px - 20px);
        overflow: auto;
        .trs {
          border-bottom: 1px solid #243A51;
          &:last-child {
            border: 0;
          }
        }
      }
      .trs {
        display: flex;
        div {
          text-align: center;
          &:nth-child(1) {
            width: 40%;
            color: #7EBBFF;
          }
          &:nth-child(2) {
            width: 40%;
            color: #7EBBFF;
          }
          &:nth-child(3) {
            width: 20%;
          }
        }
      }
    }
  }
}
</style>